% preprocess data
marm2Dpreprocessing;

% fit data
[fitobject,gof,output] = fit(xdata,ydata,'poly1','Weights',bootpars.weights);
fres.p1 = fitobject.p1;
fres.p2 = fitobject.p2;
fres.confintervalls = confint(fitobject,0.95);
fres.coeffStandardDevs = mean(abs(confint(fitobject,0.683)-mean(confint(fitobject,0.683),1)),1);

% postprocess data
marm2Dpostprocessing;

% report fit result
fitresults.fitobject = fitobject;
fitresults.gof = gof;
fitresults.output = output;
fitresults.fres = fres;
disp('Report fit standard regression')
disp('sf(x,y) = p1*x + p2')
disp('Coefficients (with 95% confidence bounds):')
disp(['p1 =      ' num2str(fres.p1) '  (' num2str(fres.confintervalls(1,1)) ',' num2str(fres.confintervalls(2,1)) ')'])
disp(['p2 =      ' num2str(fres.p2) '  (' num2str(fres.confintervalls(1,2)) ',' num2str(fres.confintervalls(2,2)) ')'])
disp(['std_p1 =      ' num2str(fres.coeffStandardDevs(1))])
disp(['std_p2 =      ' num2str(fres.coeffStandardDevs(2))])
disp(' ')

disp('Printing fres:');
fres
disp(' ');
disp('Printing GoF:');
gof
disp(' ');
disp('Printing output:');
output
disp(' ');